<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>员工列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../js/layui.2.6.8/css/layui.css" media="all">
    <style type="text/css">
        .layui-table-cell{height:40px;line-height:40px;}
    </style>
</head>
<body >
<!--搜索框-->
<!--<div class="layui-form">-->
<!--    <div class="layui-form-item" style="margin-bottom: 30px;text-align: center;">-->
<!--        <div class="layui-inline">-->
<!--            &lt;!&ndash;<label class="layui-form-label">员工姓名或编号</label>&ndash;&gt;-->
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" name="name" placeholder="请输入姓名" autocomplete="off" class="layui-input" />-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-inline">-->
<!--            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="search-qiye-submit">-->
<!--                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>-->
<!--            </button>-->
<!--        </div>-->
<!--    </div>-->
<!--</div>-->

<blockquote class="layui-elem-quote quoteBox mod_default_box">
    <form class="layui-form">
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 50px;">关键字</label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" placeholder="编号、姓名、联系方式" autocomplete="off" class="layui-input" />
            </div>
            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="search-qiye-submit">
                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label" style="width: 40px;">物业</label>
            <div class="layui-input-inline">
                <select name="city" lay-verify="" lay-filter="wuye" id="wuye" lay-search>
                    <option value="">选择物业</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 40px;">企业</label>
            <div class="layui-input-inline">
                <select name="city" lay-verify="" lay-filter="qiye" id="qiye" lay-search>
                    <option value="">选择企业</option>
                </select>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label" style="width: 40px;">国籍</label>
            <div class="layui-input-inline">
                <select name="guoji" lay-verify="" lay-filter="guoji" id="guoji" lay-search>
                    <option value="">选择国籍</option>
                </select>
            </div>
        </div>

<!--        <div class="layui-inline">-->
<!--            <label class="layui-form-label" style="width: 40px;">职业</label>-->
<!--            <div class="layui-input-inline">-->
<!--                <select name="city" lay-verify="" lay-filter="zhiye" id="zhiye" lay-search>-->
<!--                    <option value="">选择职业</option>-->
<!--                </select>-->
<!--            </div>-->
<!--        </div>-->
    </form>
</blockquote>
<!--<blockquote class="layui-elem-quote quoteBox mod_default_box">-->
<!--<form class="layui-form">-->
<!--<div class="layui-inline">-->
<!--<label class="layui-form-label">物业</label>-->
<!--<div class="layui-input-inline">-->
<!--<select name="city" lay-verify="" lay-filter="wuye" id="wuye" lay-search>-->
<!--<option value="">选择物业</option>-->
<!--</select>-->
<!--</div>-->
<!--</div>-->
<!--<div class="layui-inline">-->
<!--<label class="layui-form-label">企业</label>-->
<!--<div class="layui-input-inline">-->
<!--<select name="city" lay-verify="" lay-filter="qiye" id="qiye" lay-search>-->
<!--<option value="">选择企业</option>-->
<!--</select>-->
<!--</div>-->
<!--</div>-->
<!--<div class="layui-inline">-->
<!--<label class="layui-form-label">姓名或编号</label>-->
<!--<div class="layui-input-inline">-->
<!--<input type="text" class="layui-input searchVal" name="name" placeholder="请输入姓名或编号" />-->
<!--</div>-->
<!--<a class="layui-btn  search_btn" data-type="reload">搜索</a>-->
<!--</div>-->
<!--</form>-->
<!--</blockquote>-->
<div style="display: none" id="batchAdd"></div>
<div style="display: none" id="batchDelete"></div>
<div style="display: none" id="batchUpdateStaffWy"></div>
<!--数据列表-->
<table class="layui-hide" id="test" lay-filter="qiye-table"></table>
<script type="text/html" id="tb">
    <div class="layui-container" style="margin-left:0px;">
<!--        <a class="layui-btn layui-btn-xs" lay-event="batchAdd"><i class="layui-icon layui-icon-addition"></i>批量导入员工</a>-->
<!--        <a class="layui-btn layui-btn-xs" id="exportExcel">批量导出员工</a>-->
<!--        <a class="layui-btn layui-btn-xs" lay-event="batchDelete"><i class="layui-icon layui-icon-delete"></i>批量删除员工</a>-->
<!--        <a class="layui-btn layui-btn-xs" id="exportExcelByProblem">导出数据不规范员工列表</a>-->
<!--        <a class="layui-btn layui-btn-xs" lay-event="batchUpdateStaffWy"><i class="layui-icon layui-icon-edit"></i>批量修改员工企业</a>-->
<!--        <a style="margin-left:30px;color: blue;text-decoration: revert;"  href="/admin/staff/moban/updateStaffQy.xlsx">下载修改员工企业模板</a>-->
    </div>
</script>
<script type="text/html" id="qiye-toolbar">
    <a class="layui-btn  layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
    {{# if( d.status==1) { }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="lizhi"><i class="layui-icon layui-icon-subtraction"></i>离职</a>
    {{# } else{ }}
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="zairuzhi">再入职</a>
    {{# } }}
<!--    <a class="layui-btn layui-btn-checked layui-btn-xs" lay-event="resetPwd">重置密码</a>-->
<!--    <a class="layui-btn layui-btn-checked layui-btn-xs" lay-event="qiyeChangeRecord">企业变更记录</a>-->
    {{# if(d.cardNo != null) {}}
    <!--<a class="layui-btn layui-btn-checked layui-btn-xs" lay-event="reset_card">解除卡绑定关系</a>-->
    {{# } }}
    <!--<a class="layui-btn layui-icon-person layui-btn-xs" lay-event="set_redcontrol"><i class="layui-icon layui-icon-redcontrol"></i>设为红码监测人</a>-->
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="delete"><i class="layui-icon layui-icon-delete"></i>删除</a>
    <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>-->
    <a class="layui-btn layui-btn-xs" lay-event="more">更多 <i class="layui-icon layui-icon-down"></i></a>
</script>

<script src="../../js/layui.2.6.8/layui.js"></script>
<!--<script src="../../js/layui/layui.js"></script>-->
<!--<script src="../../js/layui/layui.all.js"></script>-->
<script src="../../js/token.js"></script>
<script src="../../js/config.js"></script>
<script>
    layui.use(['table','upload', 'element', 'dropdown'], function() {
        var $ = layui.$;
        var table = layui.table;
        var layer = layui.layer;
        var form = layui.form;
        var upload = layui.upload;
        var element = layui.element;
        var dropdown = layui.dropdown;

        var qiye = ""
        var wuye = ""
        var name = ""
        var zhiye = ""
        var guoji = ""

        table.render({
            elem: '#test'
            , id: 'staff-table-id'//重载需要
            , url: HOST+'staff/selectstaff'
            , title: '员工表'
            ,toolbar: '#tb'
            , cols: [[
                {type: 'numbers',title: '序号',width : 90}
                , {field: 'bh',align : 'center',width : 125, title: '员工编号'}
                , {field: 'name', width: 110, align: 'center', title: '姓名'}
                , {field: 'nicheng', width: 110, align: 'center', title: '昵称'}
                , {field: 'picture',align : 'center',title: '头像',width : 125,templet: function (d) {
                    if (d.picture==null || d.picture=="" || d.picture==undefined){

                    }else{
                        return "<div><img src=\""+HOST+"upload/"+d.picture+"\" onclick=\"previewImgs(this)\"></div>";
                    }
                }}
                , {field: 'guoji',align : 'center',width : 120, title: '国籍',templet: function (d) {
                        if (d.guoji=="null" || d.guoji==null || d.guoji=="undefined") return "";
                        else return d.guoji;
                    }}
                , {field: 'wyName',align : 'center',width : 125, title: '所属物业' , templet:function(res){
                    if (res.qyStatus != 1){
                        return ""
                    }else{
                        if(res.wyName != undefined) {
                            return res.wyName
                        }else{
                            return ""
                        }
                    }
                    }}
                , {field: 'qyName',align : 'center',width : 125, title: '所属企业' , templet:function(res){
                    if (res.qyStatus != 1){
                        return ""
                    }else{
                        if(res.qyName != undefined) {
                            return res.qyName
                        }else{
                            return ""
                        }
                    }
                    }}
                // , {field: 'zhiye',align : 'center',width : 140, title: '职业'}
                , {field: 'cardNo',align : 'center',width : 120, title: '员工卡号'}
                ,{field:'sex',width : 60,align : 'center', title: '性别',templet: function (d) {
                        if (d.sex==0) return "女";
                        else if (d.sex==1) return "男";
                    }
                }
                , {field: 'phone',align : 'center',width : 125,title: '联系方式'}
                , {field: 'address',align : 'center',width : 125,title: '家庭住址'}
                , {field: 'sfz',align : 'center',width : 180, title: '证件号'}
                , {field: 'csTime',align : 'center',width : 125, title: '出生日期'}
                , {field: 'rztime',align : 'center',width : 125, title: '入职时间'}
                , {field: 'status',align : 'center',width : 125, title: '状态',sort:true,templet: function (d) {
                        if (d.status==0) return "离职";
                        else if (d.status==1) return "在职";
                    }
                }

                , {field: 'message',align : 'center', width : 125,title: '备注'}
                , {field: 'dqtime',align : 'center',width : 170, title: '到期时间'}
                // , {field: 'cstime',align : 'center',width : 170, title: '出生日期'}
                // , {field: 'jfstatus', width: 110, align: 'center', title: '缴费状态', templet: function (d) {
                //         if (d.jfstatus == 0) return "正常";
                //         else if (d.jfstatus == 1) return "快到期";
                //         else if (d.jfstatus == 2) return "已到期";
                //     }
                // }
                , {toolbar: "#qiye-toolbar",align : 'center', width: 300, title: "操作",fixed: 'right'}
            ]]
            , page: true
            ,page: {
                curr: layui.data("staff_page").index
            },
            done: (res, curr, count) => {
                layui.data("staff_page", {
                    key: 'index',
                    value: curr
                });
                bindClick();
                bindClick2();
            }
        });

        $.ajax({
            url:HOST+"qiye/selectqiyes" ,
            success:function(res){
                if(res.code == 200) {
                    for(var i in res.data) {
                        $("#qiye").append("<option value='"+res.data[i].id+"'>"+res.data[i].qyname+"</option>")
                    }
                    form.render()
                }
            }
        })

        $.ajax({
            url:HOST+"wuye/selectwuyestatus" ,
            success:function(res){
                if(res.code == 0) {
                    for(var i in res.data) {
                        $("#wuye").append("<option value='"+res.data[i].id+"'>"+res.data[i].wyname+"</option>")
                    }
                    form.render()
                }
            }
        })

        //遍历职业下选框
        // $.ajax({
        //     url: HOST+"staff/getZyDic"
        //     , type: "POST"
        //     , contentType: 'application/json'
        //     , success: function (data) {
        //         $.each(data.data, function (index, item) {
        //             $('#zhiye').append(new Option(item.name, item.code));// 下拉菜单里添加元素
        //         });
        //         layui.form.render("select");
        //     }
        // });

        //遍历国籍下选框
        $.ajax({
            url: HOST+"country/selectCountry"
            , type: "POST"
            , contentType: 'application/json'
            , success: function (data) {
                $.each(data.data, function (index, item) {
                    $('#guoji').append(new Option(item.zhName, item.id));// 下拉菜单里添加元素
                });
                layui.form.render("select");
            }
        });

        //搜索操作
        form.on('submit(search-qiye-submit)', function (data) {
            name = data.field.name
            table.reload('staff-table-id', {
                where: {"name": data.field.name , "qiye": qiye , "wuye":wuye, "zhiye": zhiye, "guoji": guoji}
                , page: {
                    curr: 1
                }
            });
            return false;
        });

        form.on('select(zhiye)', function(data){
            zhiye = $("#zhiye").find("option:selected").text();
            name = $("#name").val();
            table.reload('staff-table-id', {
                where: {"qiye": qiye , "wuye":wuye , "name":name, "zhiye":zhiye, "guoji": guoji}
                , page: {
                    curr: 1
                }
            });
        });

        form.on('select(guoji)', function(data){
            guoji = $("#guoji").find("option:selected").text();
            name = $("#name").val();
            table.reload('staff-table-id', {
                where: {"qiye": qiye , "wuye":wuye , "name":name, "zhiye":zhiye, "guoji": guoji}
                , page: {
                    curr: 1
                }
            });
        });

        form.on('select(qiye)', function(data){
            qiye = data.value;
            name = $("#name").val();
            table.reload('staff-table-id', {
                where: {"qiye": qiye , "wuye":wuye , "name":name, "zhiye":zhiye, "guoji": guoji}
                , page: {
                    curr: 1
                }
            });
        });

        form.on('select(wuye)', function(data){
            wuye = data.value
            qiye = null
            name = $("#name").val();
            $.ajax({
                url:HOST+"qiye/selectqiyes" ,
                data:{wuye:wuye} ,
                success:function(res){
                    if(res.code == 200) {
                        $("#qiye option:gt(0)").remove()
                        for(var i in res.data) {
                            $("#qiye").append("<option value='"+res.data[i].id+"'>"+res.data[i].qyname+"</option>")
                        }
                        form.render()
                    }
                }
            })
            table.reload('staff-table-id', {
                where: {"qiye": qiye , "wuye":wuye, "name":name, "zhiye":zhiye, "guoji": guoji}
                , page: {
                    curr: 1
                }
            });
        });

        var uploadInst = upload.render({
            elem: '#batchAdd'
            , url: HOST+"staff/batchAddStaff"
            , accept: "file",
            shade: [0.5,'#000'],
            exts: 'xls|xlsx|xlsm|xlt|xltx|xltm'
            , before: function (obj) {
                layui.layer.load();
                console.log("obj",obj);
            }
            , done: function (res) {
                if (res.code == 200) {
                    layer.msg("导入成功！");
                    table.reload("staff-table-id");
                    var index = layui.layer.load();
                    layer.close(index);
                }
                else {
                    layer.alert(res.data, {
                        icon: 2,
                        skin: 'layer-ext-demo'
                    })
                    var  index = layui.layer.load();
                    layer.close(index);
                }

            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });

        var uploadInst = upload.render({
            elem: '#batchDelete'
            , url: HOST+"staff/batchDeleteStaff"
            , accept: "file",
            shade: [0.5,'#000'],
            exts: 'xls|xlsx|xlsm|xlt|xltx|xltm'
            , before: function (obj) {
                layui.layer.load();
                console.log("obj",obj);
            }
            , done: function (res) {
                if (res.code == 200) {
                    var index2 = layui.layer.load();
                    layer.close(index2);
                    var str = res.data.success;
                    str += "<br>";
                    str += JSON.stringify(res.data.error);
                    str = str.replace('[','');
                    str = str.replace(']','');
                    str = str.replace(/\"/g,'');
                    str = str.replace(/,/g,'');
                    layer.confirm(str, {
                        area:['60%','40%']
                    },function (index) {
                        table.reload("staff-table-id");
                        layer.close(index);
                    })
                }
                else {
                    layer.alert(res.data, {
                        icon: 2,
                        skin: 'layer-ext-demo'
                    })
                    var  index = layui.layer.load();
                    layer.close(index);
                }

            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });

        var uploadInst = upload.render({
            elem: '#batchUpdateStaffWy'
            , url: HOST+"staff/batchUpdateStaffQy"
            , accept: "file",
            shade: [0.5,'#000'],
            exts: 'xls|xlsx|xlsm|xlt|xltx|xltm'
            , before: function (obj) {
                layui.layer.load();
                console.log("obj",obj);
            }
            , done: function (res) {
                if (res.code == 200) {
                    layer.msg("修改成功！");
                    table.reload("staff-table-id");
                    var  index = layui.layer.load();
                    layer.close(index);
                }
                else {
                    layer.alert(res.data, {
                        icon: 2,
                        skin: 'layer-ext-demo'
                    })
                    var  index = layui.layer.load();
                    layer.close(index);
                }

            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });

        function bindClick() {
            $('#exportExcel').on('click',function () {
                var staffName = $("#name").val();
                var wuye = $("#wuye").val();
                var qiye = $("#qiye").val();
                var zhiye =$("#zhiye").find("option:selected").text();
                var guoji =$("#guoji").find("option:selected").text();
                var status = $("#status").val();
                layer.open({
                    type:2
                    ,title:"选择导出方式"
                    ,skin:'layui-layer-molv'
                    ,area: ['60%', '20%']
                    ,content:(encodeURI("staff_export_type.html?staffName=" + staffName + "&wuye=" + wuye + "&qiye=" + qiye + "&zhiye=" + zhiye + "&guoji=" + guoji + "&status=" + status))  //js获取url参数
                    ,success: function (index, layero) {
                        // 这里是这个弹出层打开完成后所进行的操作
                        // form.ready();
                    }
                });
            });
        }

        function bindClick2() {
            $('#exportExcelByProblem').on('click',function () {
                $("#exportExcelByProblem").attr('href',"/staff/exportExcelByProblemData");
            });
        }

        /*table.on('toolbar(qiye-table)', function (obj) {
            var data=obj.data;
            var event = obj.event;
            if (event === 'batchAdd') {

            }
        })*/
        //表操作  监听操作
        table.on('toolbar(qiye-table)', function (obj) {
            var data=obj.data;
            var event = obj.event;
            if (event === 'batchAdd') {
                $("#batchAdd").click();
            }else if (event === 'batchDelete') {
                $("#batchDelete").click();
            }else if (event == 'batchUpdateStaffWy') {
                $("#batchUpdateStaffWy").click();
            }
        })

        //表操作  监听操作
        table.on('tool(qiye-table)', function (obj) {
            var data=obj.data;
            var event = obj.event;
            //删除
            if (event === 'del') {
                layer.confirm('确认删除该员工吗？', function (index) {
                    $.ajax({
                        url: HOST+"staff/delstaff?id=" + data.id
                        , type: "GET"
                        , dataType: "json"
                        , success: function (data) {
                            if (data.code == 0) {
                                layer.msg("删除成功");
                                table.reload("staff-table-id");
                            } else {
                                layer.msg("删除失败");
                            }
                        }
                        , error: function () {
                            console.log("ajax error");
                        }
                    });
                    layer.close(index);
                });
            } else if (event === 'edit') {
                var data = obj.data;
                if (data.qyStatus != 1){
                    data.qyName = "";
                    data.qyID = "";
                }
                layer.open({
                    type:2
                    ,title:"编辑员工"
                    ,skin:'layui-layer-molv'
                    ,area: ['95%', '99%']
                    ,content:("updatestaff.html?id="+data.id+"&name="+encodeURIComponent(data.name)+"&sex="+data.sex+
                        "&phone="+encodeURIComponent(data.phone)+"&address="+encodeURIComponent(data.address)+"&bh="+data.bh+"&picture="+data.picture+
                        "&jfstatus="+data.jfstatus+"&qyName="+encodeURIComponent(data.qyName)+"&qyID="+data.qyID+"&sfz="+encodeURIComponent(data.sfz)+"&message="+encodeURIComponent(data.message)+
                        "&rztime="+data.rztime+"&status="+data.status+"&lztime="+data.lztime+"&dqtime="+data.dqtime+"&guoji="+encodeURIComponent(data.guoji)+
                        "&nicheng="+encodeURIComponent(data.nicheng)+"&cstime="+data.csTime+"&zhiye="+data.zhiye)  //js获取url参数
                    ,success: function (index, layero) {
                        // 这里是这个弹出层打开完成后所进行的操作
                        // form.ready();
                    }
                });
            }else if(event=='lizhi'){
                layer.confirm("确定离职？",function (index) {
                    $.ajax({
                        url: HOST+"staff/stafflizhi?id=" + data.id+"&status=1"
                        , type: "GET"
                        , success: function (data) {
                            if (data.code == 0) {
                                layer.msg("离职成功");
                                layer.close(index);
                                table.reload("staff-table-id");
                            } else {
                                layer.msg("离职失败");
                            }
                        }
                        , error: function () {
                            console.log("ajax error");
                        }
                    });
                })
            }else if(event=='zairuzhi'){
                // 重新入职
                layer.confirm("确定重新入职？",function (index) {
                    $.ajax({
                        url: HOST+"staff/stafflizhi?id=" + data.id+"&status=0"
                        , type: "GET"
                        , success: function (data) {
                            if (data.code == 0) {
                                layer.msg("成功入职");
                                layer.close(index);
                                table.reload("staff-table-id");
                            } else {
                                layer.msg("入职失败");
                            }
                        }
                        , error: function () {
                            console.log("ajax error");
                        }
                    });
                })
            }else if(event=='qiyeChangeRecord'){
                // 查看员工企业变更记录
                layer.open({
                    type: 2,
                    title:'企业变更记录',
                    area: ['100%', '100%'],
                    content: 'staffQiyeChangeRecord.html?staffID='+data.id, //这里content是一个普通的String
                    end: function(){
                        // location.reload();
                    }
                });
            // }else if(event=='resetPwd'){
            //     // 重新入职
            //     layer.confirm("确定重置密码？",function (index) {
            //         $.ajax({
            //             url: "/staff/resetPwd?id=" + data.id
            //             , type: "GET"
            //             , success: function (data) {
            //                 if (data.code == 200) {
            //                     layer.msg("密码重置成功");
            //                     layer.close(index);
            //                     table.reload("staff-table-id");
            //                 } else if (data.code == 500) {
            //                     layer.msg("密码重置失败");
            //                 }else {
            //                     layer.msg("拒绝访问");
            //                 }
            //             }
            //             , error: function () {
            //                 console.log("ajax error");
            //             }
            //         });
            //     })
            }else if(event === 'delete'){
                layer.prompt({
                    formType: 0,
                    value: '',
                    title: data.name + '-请输入删除原因',
                    btn: ['确定','取消'], //按钮，
                    btnAlign: 'c',
                    yes: function (index,layero) {
                        var content = layero.find(".layui-layer-input").val();
                        $.ajax({
                            url: HOST+"staff/deleteStaff?id=" + data.id + "&remark=" + content
                            ,type:"get"
                            , success: function (res) {
                                if (res.code == 200) {
                                    layer.msg("删除成功");
                                    layer.close(index);
                                    table.reload("staff-table-id");
                                } else if (res.code == 500) {
                                    layer.msg("删除失败");
                                }else {
                                    layer.msg("拒绝访问");
                                }
                            }
                            , error: function () {
                                console.log("ajax error");
                            }
                        });
                    }
                }, function(value,index){
                    layer.close(index);
                    //执行审批不通过的内容 此时获取到的数据为value
                });
            }else if(event === 'reset_card'){
                layer.confirm("确定解除卡与用户绑定关系吗？",function (index) {
                    $.ajax({
                        url: HOST+"staff/reset_card?id=" + data.id
                        , type: "GET"
                        , success: function (data) {
                            if (data.code == 200) {
                                layer.msg("解除成功");
                                layer.close(index);
                                table.reload("staff-table-id");
                            } else if (data.code == 500) {
                                layer.msg(data.msg);
                            }else {
                                layer.msg("拒绝访问");
                            }
                        }
                        , error: function () {
                            console.log("ajax error");
                        }
                    });
                })
            }/*else if(event === 'set_redcontrol'){
                layer.confirm("确定将该员工加入红码监测人员名单吗？",function (index) {
                    $.ajax({
                        url: "/redcode/monitor/add?staffId=" + data.id
                        , type: "GET"
                        , success: function (data) {
                            if (data.code == 200) {
                                layer.msg("添加成功");
                                layer.close(index);
                                table.reload("staff-table-id");
                            } else if (data.code == 500) {
                                layer.msg(data.msg);
                            }else {
                                layer.msg("拒绝访问");
                            }
                        }
                        , error: function () {
                            console.log("ajax error");
                        }
                    });
                })
            }*/else if(event === 'more') {
                var data = obj.data;
                //下拉菜单
                dropdown.render({
                    elem: this //触发事件的 DOM 对象
                    , show: true //外部事件触发即显示
                    , data: [
                    //     {
                    //     title: '设为红码检测人'
                    //     , id: 'set_redcontrol'
                    // },
                    //     {
                    //     title: '设为违规人员'
                    //     , id: 'setWg'
                    // },
                        {
                        title: '重置密码'
                        , id: 'resetPwd'
                    }
                    ]
                    ,click: function(menudata){
                        if(menudata.id === 'set_redcontrol'){
                            layer.confirm("确定将该员工加入红码监测人员名单吗？",function (index) {
                                $.ajax({
                                    url: HOST+"redcode/monitor/add?staffId=" + data.id
                                    , type: "GET"
                                    , success: function (res) {
                                        if (res.code == 200) {
                                            layer.msg("添加成功");
                                            layer.close(index);
                                            table.reload("staff-table-id");
                                        } else if (res.code == 500) {
                                            layer.msg(res.msg);
                                        }else {
                                            layer.msg("拒绝访问");
                                        }
                                    }
                                    , error: function () {
                                        console.log("ajax error");
                                    }
                                });
                            })
                        } else if(menudata.id === 'setWg'){
                            layer.prompt({
                                formType: 0,
                                value: '',
                                title: data.name + '-请输入违规描述',
                                btn: ['确定','取消'], //按钮，
                                btnAlign: 'c',
                                yes: function (index,layero) {
                                    var content = layero.find(".layui-layer-input").val();
                                    $.ajax({
                                        url: HOST+"staff/setStaffWeigui?id=" + data.id + "&remark=" + content
                                        ,type:"get"
                                        , success: function (res) {
                                            if(res.code==500) {
                                                layer.msg(res.msg);
                                            }else if(res.code==200){
                                                layer.msg('设置成功');
                                                layer.close(index);
                                                table.reload("staff-table-id");
                                            }else {
                                                layer.msg("拒绝访问");
                                            }
                                        }
                                        , error: function () {
                                            console.log("ajax error");
                                        }
                                    });
                                }
                            }, function(value,index){
                                layer.close(index);
                                //执行审批不通过的内容 此时获取到的数据为value
                            });
                        }else if(menudata.id === 'resetPwd'){
                            // 重新入职
                            layer.confirm("确定重置密码？",function (index) {
                                $.ajax({
                                    url: HOST+"staff/resetPwd?id=" + data.id
                                    , type: "GET"
                                    , success: function (data) {
                                        if (data.code == 200) {
                                            layer.msg("密码重置成功");
                                            layer.close(index);
                                            table.reload("staff-table-id");
                                        } else if (data.code == 500) {
                                            layer.msg("密码重置失败");
                                        }else {
                                            layer.msg("拒绝访问");
                                        }
                                    }
                                    , error: function () {
                                        console.log("ajax error");
                                    }
                                });
                            })
                        }
                    }
                    ,align: 'right' //右对齐弹出（v2.6.8 新增）
                    ,style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' //设置额外样式
                })
            }
        });
    });
</script>

<script>
    function previewImgs(obj) {
        var img = new Image();
        img.src = obj.src;
        //var height = img.height + 50; // 原图片大小
        //var width = img.width; //原图片大小
        var imgHtml = "<img src='" + obj.src + "' width='800px' height='500px'/>";
        //弹出层
        layer.open({
            type: 1,
            shade: 0.8,
            offset: 'auto',
            area: [800 + 'px', 550 + 'px'],// area: [width + 'px',height+'px'],  //原图显示
            shadeClose: true,
            scrollbar: false,
            title: "图片预览", //不显示标题
            content: imgHtml, //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
            cancel: function () {
                //layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', { time: 5000, icon: 6 });
            }
        });
    }
</script>
</body>
</html>